local name, ns = ...

local L = LibStub("AceLocale-3.0"):GetLocale(name)

local function getOption(info)
	local opt = info[#info]
	return WhoRoll.db.profile[opt]
end

local function setOption(info, value)
	local opt = info[#info]
	WhoRoll.db.profile[opt] = value
end

local qualityChoices = {
	[2] = "|cff1eff00Uncommon|r",
	[3] = "|cff0070ddRare|r",
	[4] = "|cffa335eeEpic|r",
}

local options = {
	name = name,
	desc = name,
	type = 'group',
	icon = [[Interface/Buttons/UI-GroupLoot-Dice-Up]],
	set = setOption,
	get = getOption,
	args = {
		maxHistory = {
			name = L["Max entries"],
			desc = L["Max entries in history"],
			type = 'range',
			min = 0,
			max = 30,
			step = 1,
		},
		qualityThreshold = {
			name = L["Quality Threshold"],
			desc = L["Only keep items with at least this quality in history"],
			type = 'select',
			values = qualityChoices,
		}
	},
}

local AceConfig = LibStub("AceConfig-3.0")
local AceConfigDialog = LibStub("AceConfigDialog-3.0")
AceConfig:RegisterOptionsTable(name, options)
AceConfigDialog:SetDefaultSize(name, 500, 350)

function WhoRoll:ShowConfig()
	AceConfigDialog:Open(name)
end